<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";

String flag = request.getParameter("flag");
%>
<div id="lynn-dep-list-01" style="background-color: gray;height: 50px;overflow: auto;">
	<% if(flag != null && flag.equals("emp")) { %>
	<h3 style="margin-bottom: 5px;">已选人员(双击移除)：</h3>
	<% } else { %>
	<h3 style="margin-bottom: 5px;">已选部门(双击移除)：</h3>
	<% } %>
</div>

<script>
	
	var selectedMD = [];
	var f = "<%=flag %>";
	var lis = function (flag,objId,name) {
		if(flag != f) return;
		if(exist(objId)) return;
		
		selectedMD.push(objId);
		var rm = "" + parseInt(Math.random()*10000 );
		$("#lynn-dep-list-01").append("<span class='"+rm+"' objId="+objId+" style='background-color:blue;margin-left:10px;'>"+name+"</span>");
		$("span."+rm).dblclick(function(event){
			var objId = $("span."+rm).attr("objId");
			rv(objId);
			$("span."+rm).remove();
		});
	}

	var exist = function (id) {
		var i = 0;
		for(i=0;i<selectedMD.length;i++){
			if(selectedMD[i] == id) return true;
		}
		return false;
	}

	var rv = function (id) {
		var i = 0;
		for(i=0;i<selectedMD.length;i++){
			if(selectedMD[i] == id) {
				selectedMD[i] = null;
			}
		}
	}

	lynn.getSelectDepList = function () {
		var i = 0;
		var s = [];
		for(i=0;i<selectedMD.length;i++)
		{
			if(selectedMD[i]!=null)
			{
				s.push(selectedMD[i]);
			}
		}
		return s;
	}

	lynnAddLis(lis);
</script>